<template>
  <div class="main-layout">
    <div class="main-top-lay">
      <Header style="flex:1;" :headHei='68' :title="systemTitle" :logo="logo" :user="userInfo"/>
    </div>
    <div class="left-main-content">
      <sidebar :menus="menus" :name="''" :active-menu="activeMenu" class="sidebar-container"/>
      <div class="main-router-lay">
        <div class="main-container main-router-lay">
          <TabRouterLayout style="flex: 1;" @tab-router-change="tabRouterChange"/>
        </div>
        <CopyRight style="margin: 8px 16px; text-align: right"/>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">

import Header from "@/components/common/PageHeader.vue";
import Sidebar from './Sidebar/index.vue'
import {useStore} from "@/stores";
import {computed, onMounted, ref, shallowRef} from "vue";
import TabRouterLayout from "@/views/layouts/TabRouterLayout.vue";
import router from "@/router";
import CopyRight from "@/widget/CopyRight.vue";

const store = useStore();

const logo = ref(store.settings.logo);
const systemTitle = shallowRef(store.settings.title);

const menus = ref<MenuType[]>(store.getMenus() || []);
const activeMenu = ref(store.getHomeRoute());

const userInfo = computed(() => {
  return store.getUser();
});

const tabRouterChange = async (path: string) => {
  if (path) {
    await router.push({path: path});
  }
}

onMounted(() => {

})

</script>

<style scoped>
.main-layout {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-top-lay {
  width: 100%;
  display: flex;
  flex-direction: row;
}

.left-main-content {
  display: flex;
  flex-direction: row;
  flex: 1;
  overflow: hidden;
  transition: margin-left .28s;
}

.main-router-lay {
  display: flex;
  flex-direction: column;
  flex: 1;
  background-color: #fff;
}

.main-router {
  flex: 1;
}

</style>
